package ai.people.platform.oss.config;

import com.aliyun.oss.OSS;
import org.springframework.core.NamedThreadLocal;

/**
 * 保存线程和OSS客户端映射
 *
 * @author yuanqinglong
 * @date 2022/4/28 15:02
 */
public class OssClientContextHolder {

    private static final ThreadLocal<OSS> requestThreadHolder = new NamedThreadLocal<>("Request attributes");

    public static void setRequestThreadHolder(OSS oss) {
        requestThreadHolder.set(oss);
    }

    public static OSS getRequestThreadHolder() {
        return requestThreadHolder.get();
    }

    public static void resetRequestThreadHolder() {
        requestThreadHolder.remove();
    }


}
